<?php include INSTALL_PATH.'view/htm/header.inc.htm';?>

<div class="container">
<form action="index.php?action=db" method="post" id="form">

<div class="row mt-3">
	<div class="col-lg-8 offset-lg-2">
		<div class="card">
			<div class="card-body">
				<div class="mb-3 text-center">
					<a target="_blank" href="http://www.wellcms.cn/"><img src="../view/img/logo.png" class="logo-2"></a>
				</div>
				<h2 class="mb-3 text-center size5"><?php echo lang('step_2_title');?></h2>
				<hr>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('db_engine');?>：</label>
					<div class="col-sm-9">
						<label><input type="radio" name="engine" value="myisam" checked /> MyISAM</label>
						<label><input type="radio" name="engine" value="innodb" /> InnoDB</label>
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('db_host');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="host" class="form-control" value="127.0.0.1">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('db_name');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="name" class="form-control" value="WellCMS">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('db_user');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="user" class="form-control" value="root">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('db_pass');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="password" class="form-control" value="root">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('db_table_pre');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="tablepre" class="form-control" value="well_">
					</div>
				</div>
				<h4><?php echo lang('step_3_title');?></h4>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('admin_email');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="adminemail" class="form-control" value="admin@admin.com">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('admin_username');?>：</label>
					<div class="col-sm-9">
						<input type="text" name="adminuser" class="form-control" value="admin">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('admin_pw');?>：</label>
					<div class="col-sm-9">
						<input type="password" name="adminpass" class="form-control" value="">
					</div>
				</div>
				<div class="form-group row">
					<label class="col-sm-3 form-control-label"><?php echo lang('admin_pw_repeat');?>：</label>
					<div class="col-sm-9">
						<input type="password" name="adminpassrepeat" class="form-control" value="">
					</div>
				</div>
			</div>
	
			<div class="text-center m-3">
				<button type="button" class="btn btn-secondary" onclick="history.back();"><?php echo lang('last_step');?></button>
				<button type="submit" class="btn btn-primary" id="submit" <?php echo !$succeed ? 'disabled' : '';?> data-loading-text="<?php echo lang('installing_about_moment');?>..."><?php echo lang('next_step');?></button>
			</div>
		</div>
	</div>
</div>

</form>
</div>
<?php include INSTALL_PATH.'view/htm/footer.inc.htm';?>

<script>
	$('body').on('submit', '#form', function () {
		var jthis = $(this);
		var jsubmit = jthis.find('#submit');
		jsubmit.button('loading');
		var postdata = jthis.serializeObject();
		if (postdata.adminpass !== postdata.adminpassrepeat) {
			jthis.find('[name="adminpassrepeat"]').alert('<?php echo lang('password_incorrect');?>').focus();
			jsubmit.button('reset');
			return false;
		}
		$.xpost(jthis.attr('action'), postdata, function (code, message) {
			if (code == 0) {
				alert(message);
				window.location = '../';
				jsubmit.button(message);
			} else if (code < 0) {
				alert(message);
				jsubmit.button('reset');
			} else {
				jthis.find('[name="' + code + '"]').alert(message).focus();
				jsubmit.button('reset');
			}
		});
		return false;
	});
</script>